package dataImport.action;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import dataImport.action.abstracts.AbstractInteractableEntityReader;
import dataImport.action.manager.EntityReaderManager;
import dataImport.model.Object;
import dataImport.model.abstracts.AbstractEntity;


public class ObjectReader extends AbstractInteractableEntityReader {

	private static final long serialVersionUID = 2654537167142745057L;

	public static final String ENTITY_NAME = "object";

	public ObjectReader(final EntityReaderManager entityReaderManager) {
		super(entityReaderManager);
	}

	@Override
	protected AbstractEntity createEntity(final Element element) {

		final String id = element.getAttribute(ATTRIBUTE_ID);
		final String name = element.getAttribute(ATTRIBUTE_NAME);

		super.verifyRestrictions(id, name);

		return new Object(id, name);
	}

	@Override
	public void read(final Document document) {
		this.read(ObjectReader.ENTITY_NAME, document);
	}
}
